<template>
	<view>
		<uni-popup ref="message" type="message">
			<uni-popup-message  :type="msgType[props.msgParams.msgType]"
				:message="props.msgParams.messageText" :duration="2000"></uni-popup-message>
		</uni-popup>
	</view>
</template>
<script setup>
	import {
		reactive,
		ref,
		watch
	} from "vue";
	const emits = defineEmits(['iceClose'])
	const props = defineProps({
		msgParams: {
			type: Object
		}
	})
	const message = ref(null)
	const msgType = reactive({
		s: 'success',
		e: 'error',
		w: 'warn',
		i: 'info',
	})
	// 为什么父组件传过来的 'success' 就可以
	// console.log(msgType.value['success']);
	watch(
		() => props.msgParams.isOpen,
		(n) => {
			if (n) {
				console.log(props.msgParams.msgType);
				message.value.open()
				emits('iceClose')
			}
		}, {
			immediate: true,
			deep: true
		}
	)
</script>
<style scoped>
</style>